import psycopg2
# 连接到 PostgreSQL 数据库
conn = psycopg2.connect(
    dbname="nmg_info",
    user="postgres",
    password="此处填写数据库密码",
    host="localhost",
    port="5432"
)
cursor = conn.cursor()
# 更新数据
cursor.execute('''
UPDATE population.population_info
SET total_population = %s
WHERE region_id = %s AND year = %s
''', (2410.5, 101, 2023))
# 提交事务
conn.commit()
# 关闭连接
conn.close()
print('数据更新成功！')
